package net.canang.codegen.engine.util;

/**
 * todo: comment
 */
public class Util {

    /**
     * @see #instanceOf(Class,String)
     */
    static public boolean instanceOf(Object o, String className) {
        return instanceOf(o.getClass(), className);
    }

    /**
     * @return whether or not <tt>c</tt> is an instance of
     *         <tt>className</tt>.
     */
    static public boolean instanceOf(Class c, String className) {
        if (c.getName().equals(className))
            return true;
        Class[] ifcs = c.getInterfaces();
        for (int i = 0; i < ifcs.length; i++)
            if (instanceOf(ifcs[i], className))
                return true;
        c = c.getSuperclass();
        if (c != null) return instanceOf(c, className);
        return false;
    }

}
